import axios from 'axios'
import { userStore } from '@/stores/user.js'
const store = userStore()
const token = store.userInfo.token
export const getNewsServe = ({ page, size }) =>
  axios.get(
    `http://localhost/hu/public/news?page=${page}&size=${size}&token=${token}`
  )

export const addNewsServe = (data) =>
  axios.post('http://localhost/hu/public/news', data)
export const putNewsServe = (data) =>
  axios.post(`http://localhost/hu/public/news/edit/${data.get('id')}`, data)

export const delNewsServe = ({ id, isdelete }) =>
  axios.delete(`http://localhost/hu/public/news/${id}?token=${token}`, {
    id,
    isdelete,
    loginname: token
  })

export const getNews = (id) =>
  axios.get(`http://localhost/hu/public/news/${id}`)
